{include file="common/head"/}
<div class="admin-main layui-anim layui-anim-upbit" ng-app="hd" ng-controller="ctrl">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>{$title}</legend>
    </fieldset>
    <form class="layui-form layui-form-pane">
        <div class="layui-form-item">
            <label class="layui-form-label">所属用户组</label>
            <div class="layui-input-4">
                <select name="level" lay-verify="required" ng-model="field.level" lay-filter="level" ng-options="v.level_id as v.level_name for v in group" ng-selected="v.level_id==field.level">
                    <option value="">请选择会员组</option>
                </select>  
            </div>
        </div> 
        <div class="layui-form-item" id="agentlvid" style="display: none;"  >
            <label class="layui-form-label">代理手续费</label>
            <div class="layui-input-4">
                <input type="text" name="agentlv" ng-model="field.agentlv" placeholder="%依次为【微信|支付宝|银行卡】,以“|”隔开" class="layui-input">
            </div> 
        </div> 
        <div class="layui-form-item">
            <label class="layui-form-label">上级ID号</label>
            <div class="layui-input-4">
                <input type="text" name="agentid" ng-model="field.agentid"  placeholder="{:lang('pleaseEnter')}上级ID号" class="layui-input">
            </div> 
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">码商手续费</label>
            <div class="layui-input-4">
                <input type="text" name="userlv" ng-model="field.userlv"  placeholder="%依次为【微信|支付宝|银行卡】,以“|”隔开" class="layui-input">
            </div> 
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">码商姓名</label>
            <div class="layui-input-4">
                <input type="text" name="username" ng-model="field.username" lay-verify="required" placeholder="{:lang('pleaseEnter')}{:lang('nickname')}" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('tel')}</label>
            <div class="layui-input-4">
                <input type="text" name="mobile" ng-model="field.mobile" lay-verify="phone" placeholder="输入{:lang('tel')}" class="layui-input">
            </div> 
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('email')}</label>
            <div class="layui-input-4">
                <input type="text" name="email" ng-model="field.email" lay-verify="email" placeholder="输入{:lang('email')}" class="layui-input">
            </div> 
        </div>
        <div class="layui-form-item" style="text-align: center;width: 100%">
            <input id="f_cardid" name="f_cardid" type="hidden">
            <div class="layui-upload-drag" id="f_cardid_up" style="display: block;">
                <div class="bttext"><i class="layui-icon">&#xe608;</i><p>点击上传身份证正面</p></div>
            </div> 
        </div>

         <div class="layui-form-item" style="text-align: center;width: 100%">
            <input id="s_cardid" name="s_cardid" type="hidden">
            <div class="layui-upload-drag" id="s_cardid_up" style="display: block;">
                <div class="bttext"><i class="layui-icon">&#xe608;</i><p>点击上传身份证反面</p></div>
            </div> 
        </div> 
        <div class="layui-form-item">
            <label class="layui-form-label">登录{:lang('pwd')}</label>
            <div class="layui-input-4">
                <input type="password" name="password" placeholder="输入登录{:lang('pwd')}" class="layui-input">
            </div> 
        </div> 
        <div class="layui-form-item">
            <label class="layui-form-label">支付密码</label>
            <div class="layui-input-4">
                <input type="text" name="paypwd" class="layui-input"  placeholder="{:lang('pleaseEnter')}支付密码，不填则默认为123456" >
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">押金</label>
            <div class="layui-input-4">
                <input type="text" name="deposit" ng-model="field.deposit" class="layui-input" placeholder="{:lang('pleaseEnter')}押金，可不填">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">单笔提现额度</label>
            <div class="layui-input-4">
                <input type="text" name="one_cash" ng-model="field.one_cash" class="layui-input" placeholder="{:lang('pleaseEnter')}单笔提现额度，可不填">
            </div>
        </div>
        <div class="layui-form-item"> 
            <button type="button" class="layui-btn layui-btn-fluid" lay-submit="" lay-filter="submit">{:lang('submit')}</button> 
        </div>
    </form>
</div>
{include file="common/foot"/}
<script src="/static/common/js/angular.min.js"></script>
<script>
    var m = angular.module('hd',[]);
    m.controller('ctrl',function($scope) { 
        $scope.group = {$user_level|raw}; 
        layui.use(['form', 'layer'], function () {
            var form = layui.form, layer = layui.layer,$= layui.jquery;  
            form.on('select(level)', function(data) {
                var leven = data.value;
                var levenid=leven.substring(7,leven.length);
                if(levenid>1){  
                    $("#agentlvid" ).css({display:"block"});   
                }else{
                    $("#agentlvid" ).css({display:"none"}); 
                }
            });

            form.on('submit(submit)', function (data) {
                // 提交到方法 默认为本身
                var loading = layer.load(1, {shade: [0.1, '#fff']}); 
                $.post("", data.field, function (res) {
                    layer.close(loading);
                    if (res.code > 0) {
                        layer.msg(res.msg, {time: 1800, icon: 1}, function () {
                           parent.location.reload();
                        });
                    } else {
                        layer.msg(res.msg, {time: 1800, icon: 2});
                    }
                });
            })
        });
    });
</script>
<script>
layui.use(['jquery','form','upload'], function(){
    var $ = layui.jquery ,upload = layui.upload,form = layui.form;   
    form.on('select(name_en)', function(data){
        var name=$("#name_en option:checked").text(); 
        $('#name').val(name);  
    }); 
      //身份证正面上传
    up_f_cardid=upload.render({
        elem: '#f_cardid_up'
        ,url: '{:url("UpFiles/upload")}' 
        ,done: function(res){ 
            if(res.code>0){
                $('#f_cardid').val(res.url);
                $('#f_cardid_up').html("<img src="+res.url+" height=72>");
            }else{ 
                return layer.msg(res.info);
            }
        } 
    });
     //身份证反面上传
    up_s_cardid=upload.render({
        elem: '#s_cardid_up'
        ,url: '{:url("UpFiles/upload")}' 
        ,done: function(res){ 
            if(res.code>0){
                $('#s_cardid').val(res.url);
                $('#s_cardid_up').html("<img src="+res.url+" height=72>");
            }else{ 
                return layer.msg(res.info);
            }
        } 
    });
    // 提交监听
    form.on('submit(addbtn)', function (data) {   
        $.post("{:url('admin/users/add')}",data.field,function(res){ 
            if(res.code===1){
                layer.msg(res.msg,{time:2000,icon:1},function(){  
                    parent.location.reload();
                });
            }else{
                layer.msg(res.msg,{time:1000,icon:2}); 
            }
        });
        return false;
    });
}); 
</script> 
</body>
</html>